--
-- Author: shunguo.chen
-- Date: 2017-12-18 16:33:26
--
-- MountSummonView  激活坐骑界面

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.MountSummonScene

local SOUL_NUM_STR = L("lua_code_text_466")

function ClassRef:init()
    display.setCascadeOpacityEnabled(self._root, true)
    self._ui.Button_cancel:addClickEventListener(function()
        self:closeView()
        -- executeFunc(self.closeView, self)
    end)
    self._ui.Button_ok:addClickEventListener(function()
        self:hide(function()
            executeFunc(self._onOperate, "summonMount", self._data)
            executeFunc(self._onCloseView, self)
        end)
    end)

    local con = self._ui["Panel/Panel_content/Panel_bar"]
    self._bar = con:getChildByName("LoadingBar")
    self._numText = con:getChildByName("num")

    self._icon = self._ui["Panel/icon_1/icon"]
end

function ClassRef:refresh(mount)
    self._data = mount
    self._ui.tlt:setString(mount:getName())
    self._icon:loadTexture(mount:getIconBig())

    local haveNum, needNum = mount:getQualityCostNum()
    self._bar:setPercent(haveNum/needNum * 100)
    self._numText:setString(string.format(SOUL_NUM_STR, haveNum, needNum))
end

return ClassRef